﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;
using System.Data.Common;
using DataBase.Daihoctuonglai;

namespace Dhtl_Repositry.UnitOfWork
{
    public class WorkUnit : IUnitOfWork, IDisposable
    {
        public Dai_hoc_tuong_laiEntities Context { get; private set; }

        public WorkUnit()
        {
            Context = DbContextUtils.CreateDbContext<Dai_hoc_tuong_laiEntities>(); 
        }

        public void Save()
        {
            if (Context != null)
            {
                Context.SaveChanges();
            }
        }

        public void RollBack()
        {
            throw new NotImplementedException();
        }

        public void Dispose()
        {
            if (Context != null)
            {
                Context.Dispose();
                Context = null;
            }
        }
    }
}
